var {
  getWorkList
} = require('../../utils/api');
const app = getApp();


Page({
 data: {
 currentTab: 0,
 uname:'',
 workList:[],
 workListAsy:[],
 workListAny:[],
 },

 onLoad: function (options) {
  let _this = this;
  //获取设备的宽高
  wx.getSystemInfo({
    success: function (res) {
      _this.setData({
        clientHeight: res.windowHeight,
        uname:app.globalData.userInfo.name
      });
    }
  })

  getWorkList(app.globalData.id).then((res)=>{
    console.log(res);
    if(res[1].length > 0){
      let array = res[1],asy=[],any=[];
      for(let i = 0;i < array.length;i++){
        if(array[i].eventStatus == 2){//待处理
          asy.push(array[i])
        }else if(array[i].eventStatus == 3 || array[i].eventStatus == 4){
          any.push(array[i])
        }
      }

      _this.setData({
        workList: array,
        workListAsy:asy,
        workListAny:any
      });
    }
  })
 },
//我的事件页面-左右滑动
bindChange: function (e) {
 console.log("滑动切换会触发的事件")
 var that = this;
 that.setData({
   currentTab: e.detail.current
 });
},
 //跳转到事件详情页面--带有顶部tabbar的页面
 openorder(e) {
  console.log('111111', e.currentTarget.dataset.id);
  let id = e.currentTarget.dataset.id;
  wx.navigateTo({
    url: "../workinfo/index?id=" + id,
  })
},

//点击顶部的btabbar切换
swichNav: function (e) {
 var that = this;
 console.log('=======index====', e.target.dataset.current);
 if (this.data.currentTab === e.target.dataset.current) {
   return false;
 } else {
   that.setData({
     currentTab: e.target.dataset.current
   })
 }
},





})